package com.p.lib.widget.fontview.textview;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;

import com.p.lib.app.BaseApplication;

/**
 * Created by Administrator on 2018/6/8 0008.
 */

public class FontTextView extends android.support.v7.widget.AppCompatTextView {

    private static Typeface yuanti;
    public static Typeface getYuanti(Context context) {
        if(yuanti == null){
//            yuanti = Typeface.createFromAsset(context.getResources().getAssets(), "fonts/Lantinghei_s.ttf");

            if(BaseApplication.isEnglish()){
                yuanti = Typeface.createFromAsset(context.getResources().getAssets(), "fonts/SFUITextCondensed-Regular.otf");
            }else{
                yuanti = Typeface.createFromAsset(context.getResources().getAssets(), "fonts/Lantinghei_s.ttf");
            }
        }
        return yuanti;
    }

    public static void reset(){
        yuanti = null;
    }

    public FontTextView(Context context) {
        this(context, null);
    }

    public FontTextView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public FontTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        this.setTypeface(getYuanti(context));
    }
}
